package com.ssyt.yt1.day15;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * try...catch...finally、throws、throw综合使用
 * 
 * @author Administrator
 *
 */
public class ExceptionDemo2 {

	/**
	 * 
	 * @param a
	 *            转进来的值必须在1~100之间
	 */
	public static void add(int a) {
		Scanner scanner = new Scanner(System.in);
		try {
			if (a < 1 || a > 100) {
				throw new Exception("转进来的值必须在1~100之间");
			}
			System.out.println(scanner.nextInt() + a);
		} catch (InputMismatchException e) {
			// e.printStackTrace();
			// System.out.println("输入必须为数字");
		} catch (Exception e) {
			e.printStackTrace();
			throw new IllegalArgumentException();
		} finally {
			scanner.close();
		}
	}

	public static void main(String[] args) {
		add(1000);
	}
}
